package com.itheima.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * @author Encounter
 * @date 2024/10/14 13:02<br/>
 */
@Mapper
public interface MemberMapper
    {
        /**
         * 获取成员计数
         *
         * @return {@link List }<{@link Map }<{@link String }, {@link Object }>>
         */
        @Select("""
                select last_day(min(regTime)) months, count(*) memberCount
                from t_member
                group by month(regTime)
                order by months""")
        List<Map<String, Object>> getMemberCount();
        
        /**
         * 立即获取新会员
         *
         * @param today 今天
         * @return {@link Integer }
         */
        @Select("select count(*) from t_member where regTime = #{today}")
        Integer getTodayNewMember(String today);
        
        /**
         * 获取新会员
         *
         * @param begin 开始
         * @param end   结束
         * @return {@link Integer }
         */
        @Select("select count(*) from t_member where regTime >= #{begin} and regTime <= #{end}")
        Integer getNewMember(String begin, String end);
        
        /**
         * 获取总会员
         *
         * @return {@link Integer }
         */
        @Select("select count(*) from t_member")
        Integer getTotalMember();
    }
